

#include <stdio.h>
#include <stdlib.h>

typedef char bool;
#define False (1==0)
#define True (1==1)
#define ERROR -1

int prog_search(float expect,float * array,int _index_);

int main(int argc,char *argv[]){float array[1000], * arrayp = array;

        arrayp[0] = 0.5;
        int result = prog_search(8215,arrayp,1000);
        if (result == ERROR) printf ("\nalgoritmo chegou ao máximo\n\n");
        else printf("\nBool : %d\n",result);
        return 0;
    
}int prog_search(float expect,float * array,int _index_){
        bool Bool = True;
        int search_algoritmo = 0,search_algo_entrada[26];
	register int search;
        float razon = 0.000,increment = 1;
        while (Bool){
            
                if (array[search] > expect){
                    razon = 0.000;
                    switch (search_algoritmo){
                        
                        case 1: increment = 0.9000;	search_algo_entrada[0]=1;  break;
                        case 2: increment = 0.8000;	search_algo_entrada[1]=1;  break;
                        case 3: increment = 0.7000;	search_algo_entrada[2]=1;  break;
                        case 4: increment = 0.6000;	search_algo_entrada[3]=1;  break;
                        case 5: increment = 0.5000;	search_algo_entrada[4]=1;  break;
                        case 6: increment = 0.4000;	search_algo_entrada[5]=1;  break;
                        case 7: increment = 0.3000;	search_algo_entrada[6]=1;  break;
                        case 8: increment = 0.2000;	search_algo_entrada[7]=1;  break;
                        case 9: increment = 0.1000;	search_algo_entrada[8]=1;  break;
                        
                        
                        case 10: increment = 0.1111;	search_algo_entrada[10]=1; break;
                        case 11: increment = 0.1110;	search_algo_entrada[11]=1; break;
                        case 12: increment = 0.1101;	search_algo_entrada[12]=1; break;
                        case 13: increment = 0.1100;	search_algo_entrada[13]=1; break;
                        case 14: increment = 0.1011;	search_algo_entrada[14]=1; break;
                        case 15: increment = 0.1010;	search_algo_entrada[15]=1; break;
                        case 16: increment = 0.1001;	search_algo_entrada[16]=1; break;
                        case 17: increment = 0.1000;	search_algo_entrada[17]=1; break;
                         
                        case 18: increment = 0.0111;	search_algo_entrada[18]=1; break;
                        case 19: increment = 0.0110;	search_algo_entrada[19]=1; break;
                        case 20: increment = 0.0101;	search_algo_entrada[20]=1; break;
                        case 21: increment = 0.0100;	search_algo_entrada[21]=1; break;
                        case 22: increment = 0.0011;	search_algo_entrada[22]=1; break;
                        case 23: increment = 0.0010;	search_algo_entrada[23]=1; break;
                        case 24: increment = 0.0001;	search_algo_entrada[24]=1; break;

                        default : return -1;

                        }
                }
        razon += increment;
        for(search =1;search < _index_;search++) {
                array[search] = (float) (array[0] + ((search -1) * razon));
                if (array[search] == expect){ 
                        Bool = False;
               }else if (array[search] > expect){
			printf ("\n\nrazon maior : %d\n\n",search_algoritmo++);
                        sleep(1.5);
			break;
              }printf("Memory : %p  :: a1  :: %2.4f  :: razão : %2.4f  :: Termo : %2.d  :: Value.Termos : %4.5f  :: expect : %2.4f  :: ax : %s  :: __search__ : %2.d/25\n",&array[search],array[0],razon,search,array[search],expect,((array[search] == expect) ? "True" : "False"),search_algoritmo);
           }
    
        }if (! Bool) printf ("\n\nPesquisa : Completada \nRazão : %f \ttermo[%d] : %f\nalgoritmos usados :\t",razon,search,array[search]);
        putchar('[');
        for(search = 0;search_algo_entrada[search];search++)
        {
            printf("%d,",search_algo_entrada[search]);
            
        }putchar(']');
        return 1;
    }
    
    
  
/*
Bool function(int ** );
int main(int argc, char * argv[]){char retorno;
    int   a[10]= {0,10,20,30,40,50,60,70,80,90};
    int * pt[1] = { a };
    retorno = function(&pt[0]);
    printf("%d\n",retorno);
    int aa;
    int *ponteiro = &aa;
    *ponteiro = 2;
    printf((2+2) ? "condicional ternary" : "impossible");
    putchar('\n');
    return 0;
}Bool function(int ** ppt){
    printf("endereço de ppt : %p\n",&ppt);
    printf("endereço de pt  : %p\n",ppt);
    printf("endereço de a   : %p\n",*ppt+2);
    printf("valor de a[4]      : %d\n",*((*ppt)+4));
    return True;
}*/

